
package com.shop.cloud.mall.common.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.shop.cloud.mall.common.enums.OrderItemEnum;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

import io.swagger.v3.oas.annotations.media.Schema;

/**
 * 商城订单详情
 *
 * @author
 * @date 2019-09-10 15:31:40
 */
@Data
@TableName("order_item")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "商城订单详情")
public class OrderItem extends Model<OrderItem> {
	private static final long serialVersionUID = 1L;

	/**
	 * PK
	 */
	@Schema(description = "PK")
	@TableId(type = IdType.ASSIGN_ID)
	private String id;
	/**
	 * 所属租户
	 */
	@Schema(description = "所属租户")
	private String tenantId;
	/**
	 * 店铺Id
	 */
	@Schema(description = "店铺Id")
	private String shopId;
	/**
	 * 逻辑删除标记（0：显示；1：隐藏）
	 */
	@Schema(description = "逻辑删除标记")
	private String delFlag;
	/**
	 * 创建时间
	 */
	@Schema(description = "创建时间")
	private LocalDateTime createTime;
	/**
	 * 最后更新时间
	 */
	@Schema(description = "最后更新时间")
	private LocalDateTime updateTime;
	/**
	 * 订单编号
	 */
	@Schema(description = "订单编号")
	private String orderId;
	/**
	 * 商品Id
	 */
	@Schema(description = "商品Id")
	private String spuId;
	/**
	 * 商品名
	 */
	@Schema(description = "商品名")
	private String spuName;
	/**
	 * 规格信息
	 */
	@Schema(description = "规格信息")
	private String specInfo;
	/**
	 * skuId
	 */
	@Schema(description = "skuId")
	private String skuId;
	/**
	 * 图片
	 */
	@Schema(description = "图片")
	private String picUrl;
	/**
	 * 商品数量
	 */
	@Schema(description = "商品数量")
	private Integer quantity;
	/**
	 * 购买单价
	 */
	@Schema(description = "购买单价")
	private BigDecimal salesPrice;
	/**
	 * 运费金额
	 */
	@Schema(description = "运费金额")
	private BigDecimal freightPrice;
	/**
	 * 支付金额（购买单价*商品数量+运费金额-积分抵扣金额-电子券抵扣金额）
	 */
	@Schema(description = "支付金额（购买单价*商品数量+运费金额-积分抵扣金额-电子券抵扣金额）")
	private BigDecimal paymentPrice;
	/**
	 * 支付积分
	 */
	@Schema(description = "支付积分")
	private Integer paymentPoints;
	/**
	 * 电子券支付金额
	 */
	@Schema(description = "电子券支付金额")
	private BigDecimal paymentCouponPrice;
	/**
	 * 积分抵扣金额
	 */
	@Schema(description = "积分抵扣金额")
	private BigDecimal paymentPointsPrice;
	/**
	 * 用户等级折扣金额
	 */
	@Schema(description = "用户等级折扣金额")
	private BigDecimal paymentUserGradeDiscountPrice;
	/**
	 * vip折扣金额
	 */
	@Schema(description = "vip折扣金额")
	private BigDecimal paymentVipDiscountPrice;
	/**
	 * 用户电子券ID
	 */
	@Schema(description = "用户电子券ID")
	private String couponUserId;
	/**
	 * 备注
	 */
	@Schema(description = "备注")
	private String remark;
	/**
	 * 状态0：正常；1：退款中；12、拒绝退款；2：退货退款中；22：拒绝退货退款；3：完成退款；4：完成退货退款；212：收到退货拒绝退款
	 */
	@Schema(description = "状态0：正常；1：退款中；12、拒绝退款；2：退货退款中；22：拒绝退货退款；3：完成退款；4：完成退货退款；212：收到退货拒绝退款")
	private String status;
	/**
	 * 是否退款0:否 1：是
	 */
	@Schema(description = "是否退款0:否 1：是")
	private String isRefund;
	/**
	 * 供应商ID
	 */
	@Schema(description = "供应商ID")
	private String supplierId;
	/**
	 * 订单物流ID
	 */
	@Schema(description = "订单物流ID")
	private String logisticsId;
	/**
	 * 发货类型（1、发物流 2、配送 3、虚拟发货）
	 */
	@Schema(description = "发货类型（1、发物流 2、配送 3、虚拟发货）")
	private String deliveryType;
	/**
	 * 发货时间
	 */
	@Schema(description = "发货时间")
	private LocalDateTime deliveryTime;
	/**
	 * 状态1：申请退款；2、拒绝退款；3、同意退款
	 */
	@Schema(description = "状态")
	@TableField(exist = false)
	private String statusDesc;

	public String getStatusDesc() {
		if (this.status == null) {
			return null;
		}
		return OrderItemEnum.valueOf(OrderItemEnum.STATUS_PREFIX + "_" + this.status).getDesc();
	}

	@TableField(exist = false)
	private List<OrderRefunds> listOrderRefunds;
}
